$(function () {
            $.ajax({
                url: projectPath + '/base/menus/left',
                type:'POST',
                async:false,
                dataType:'json',
                success:function (data) {
                    if(data!=null&&data!=''){
                        var obj = data.data;
                        for(var i in obj){
                            var str='';
                            str += '<li><a href="#"><i class="'+obj[i].icon+'"></i><span class="nav-label">'+obj[i].name+'</span><span class="fa arrow"></span></a><ul class="nav nav-second-level">';
                            var child = obj[i].childMenu;
                            for(var j in child){
                                str += '<li><a class="J_menuItem" href="'+child[j].url+'?'
                                var buttn=child[j].grandson;
                                var btnPerms = '';
                                for (var k in buttn){
                                    btnPerms += ',' + buttn[k].perms;
                                }
                                btnPerms = btnPerms.substr(1);
                                str += btnPerms;
                                str += '"><i class="'+child[j].icon+'"></i>'+child[j].name+'</a></li>';
                            }
                            str += '</ul></li>'
                            $('#side-menu').append(str);
                        }
                    }else{
                        $("#displays").css("display","none");
                    }
                    $('#side-menu').metisMenu('dispose');
                    $("#side-menu").metisMenu();
                },
                error:function (data) {
                    alert(data.data)
                }
            })
});

function downloadJSAtOnload() {
    var element = document.createElement("script");
    element.src = projectPath+"/static/lib/plugins/contabs.min.js";
    document.body.appendChild(element);
}
if (window.addEventListener)
    window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
    window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;